@echo off
@setlocal enableextensions
@cd /d "%~dp0"

echo.
echo Script to reinstall the service. A backup will be done first.
echo.
pause
echo.
echo.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\installutil /u "%ProgramFiles%\CentrisScraper\installed\CentrisScraper.WindowsService.exe"

echo.
echo.

set hour=%time:~0,2%
if "%hour:~0,1%"==" " set hour=0%time:~1,1%
set backupfolder=%date:~10,4%_%date:~4,2%_%date:~7,2%_%hour%_%time:~3,2%_%time:~6,2%
md "%ProgramFiles%\CentrisScraper\old_%backupfolder%"
xcopy "%ProgramFiles%\CentrisScraper\installed\*.*" "%ProgramFiles%\CentrisScraper\old_%backupfolder%\" /s/Y/Q

xcopy *.* "%ProgramFiles%\CentrisScraper\installed\" /s/Y/Q

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\installutil /i "%ProgramFiles%\CentrisScraper\installed\CentrisScraper.WindowsService.exe"

echo.
echo.
echo DONE!
:loop
echo.
echo.
echo Get the service state (loop). [sc query "CentrisScraper"]
pause
echo ==============================================================
echo ==============================================================
sc query "CentrisScraper"
echo ==============================================================
echo ==============================================================
goto loop
